﻿
namespace HSS.ServiceModel
{
	#region Using Directives
	using System;
	using System.ServiceModel;
	using HSS.ServiceModel.Internal;
	#endregion

	#region VirtualChannelFactory
	/// <summary>
	/// Dynamic ChannelFactory Generator.
	/// </summary>
	public static class VirtualChannelFactory
	{
		/// <summary>
		/// Creates a ChannelFactory Type by dynamically generating an asynchronous
		/// version of the provided synchronous service interface.
		/// </summary>
		/// <param name="synchronousInterface">The synchronous service interface Type.</param>
		/// <returns>The ChannelFactory Type for the asynchronous version of the service interface.</returns>
		public static Type GetChannelFactoryType(Type synchronousInterface)
		{
			var type = AsyncServiceInterfaceFactory.Instance.Generate(synchronousInterface);
			return typeof(ChannelFactory<>).MakeGenericType(type);
		}
	}
	#endregion
}